Using the pattern Attribute in HTML
The pattern attribute in HTML allows you to define a regular expression that the input value must match before the form can be submitted. It’s commonly used for custom validation rules beyond what built-in input types provide.
Works with text-based inputs like text, email, password, and search.
The value must match the regex pattern for the form to submit successfully.
If the value doesn’t match, the browser prevents submission and shows an error message.
The title attribute can be used alongside pattern to provide a helpful hint about the required format.